<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ include file="/common/taglibs.jsp"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户列表</title>
<link rel="stylesheet" type="text/css" href="${ctx}/css/easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/css/easyui/demo.css">
	<link rel="stylesheet" type="text/css" href="${ctx}/css/easyui/themes/icon.css">
	<script type="text/javascript" src="${ctx}/js/easyui/jquery-1.8.0.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="${ctx}/js/easyui/src/jquery.parser.js"></script>
	 <script type="text/javascript" src="${ctx}/js/scripts/JSONUtil.js"></script>
	 <script type="text/javascript" src="${ctx}/js/easyui/local/easyui-lang-zh_CN.js"></script>
	 <script type="text/javascript">
	 
	 $(function(){
			$('#userList').datagrid({
				
				iconCls:'icon-save',
				fitColumns:true,
				nowrap: true,
				fit:true,
				striped: true,
				collapsible:true,
				url:'${ctx}/user/getUserList',
				sortName: 'id',
				sortOrder: 'desc',
				remoteSort: false,
				idField:'id',
				frozenColumns:[[
	                {field:'id',checkbox:true}
				]],
				columns:[[
				          {field:'username',title:'用户名',width:100},
				          {field:'nickname',title:'昵称',width:100},
				          {field:'password',title:'密码',width:100},
				          {field:'createDate',title:'创建日期',width:100},
				          {field:'updateDate',title:'修改日期',width:100},
				          {field:'email',title:'邮箱',width:200,align:'left'}
				]],
				pagination:true,
				rownumbers:true,
				toolbar:"#toolbar"
			});
			var p = $('#userList').datagrid('getPager');
			$(p).pagination({
				onBeforeRefresh:function(){
					alert('before refresh');
				}
			});
			
			
		});
	
	 /* 模态方式打开供应商考核标准录入页面 */
	    function addTab(){
	    	var  iWidth=880; //模态窗口宽度
	    	var  iHeight=280;//模态窗口高度
	    	var iTop=(window.screen.height-iHeight)/2; 
	    	var iLeft=(window.screen.width-iWidth)/2; 

	      var param="";
	      param = "?operWay=1" ;
	      var openStatus = "width=880,height=280,menubar=no,toolbar=no,top="+iTop+",left="+iLeft+",Location=no,scrollbars=no,status=no,modal=yes";
	      
	      window.open("${ctx}/user/userAddOrUpdate"+param, "", openStatus);
	     
	    }
	function editTab(){
		var  iWidth=880; //模态窗口宽度
    	var  iHeight=280;//模态窗口高度
    	var iTop=(window.screen.height-iHeight)/2; 
    	var iLeft=(window.screen.width-iWidth)/2; 
		var param="";
		 var rows = $("#userList").datagrid("getSelections");
	      if (rows.length == 0) {
	        $.messager.alert("请选择一条信息","提示");
	        return;
	      }
	      var id = rows[0].id;
		param = "?operWay=2&id="+id ;
		var openStatus = "width=880,height=280,menubar=no,toolbar=no,top="+iTop+",left="+iLeft+",Location=no,scrollbars=no,status=no,modal=yes";
		
		window.open("${ctx}/user/userAddOrUpdate"+param, window, openStatus);
		
	    
		
	}
	function viewTab(){
		
	}
	function searchTab(){
		
	}
	
	  /* 刷新DataGrid表单 */
    function refreshGrid(params){
      if(typeof params == "undefined" || params == null){
         params = {};
      }
      $('#userList').datagrid("options").pageNumber = 1;   
      //分页栏上跳转到第一页   
      $('#userList').datagrid('getPager').pagination({pageNumber: 1});
      // 刷新DataGrid表单
      $("#userList").datagrid('reload',params);
      $('#userList').datagrid('clearSelections');
    }
	$(window).resize(function(){
		$('#userList').datagrid('resize', {
		width:function(){return document.body.clientWidth;},
		height:function(){return document.body.clientHeight;},
		});
		});
	</script>
	 <style type="text/css">
    html, body{
        margin:0;padding:0;border:0;width:100%;height:100%;overflow:hidden;
    }    
    </style>
	
</head>
<body >
   <div id="toolbar">
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="addTab()">添加</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editTab()">编辑</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-view" plain="true" onclick="editTab()">New</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-view" plain="true" onclick="editTab()">Destroy</a>
    </div>
          <table  id="userList" class="easyui-datagrid"  cellpadding="0" cellspacing="0" border="0" ></table>
           
</body>
</html>